package com.devops.constant;

/**
 * @Author heyabo
 * @Description 资源类型的枚举类
 * @Date 14:54 2022/6/8
 * @Param
 * @return
 **/
public enum DOSResourceEnum {

    DATABASE(1,"数据库"),
    MQ(2,"消息队列"),
    CACHE(3,"缓存"),
    REGISTRATION_CENTER(4,"注册中心"),
    CODE_ESCROW(5,"代码托管"),
    IC(6,"持续集成"),
    CONFIG_CENTER(7,"配置中心");

    private Integer type;

    private String value;

    DOSResourceEnum(int type, String value) {
        this.type = type;
        this.value = value;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public static String getValueByType(Integer type){
        for (DOSResourceEnum enums : DOSResourceEnum.values()){
            if (enums.type.intValue() == type.intValue()){
                return enums.value;
            }
        }

        return "";
    }

    public static Integer getTypeByValue(String value){
        for (DOSResourceEnum enums : DOSResourceEnum.values()){
            if (enums.value.equals(value)){
                return enums.type;
            }
        }

        return 0;
    }
}
